From 29b24cdbe73f33c1dae889b539d5edfb78f1c6f8 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 9 Mar 2015 09:49:33 -0700 Subject: [PATCH] Improve experience with the flexible target specification When calculating the output directory filename, only use the "file name" component of the target triple specified as otherwise the output could be placed into an odd location. Closes #1390 --- src/cargo/ops/cargo_rustc/layout.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/layout.rs b/src/cargo/ops/cargo_rustc/layout.rs index 1f6b2e50e..33ea8af69 100644 --- a/src/cargo/ops/cargo_rustc/layout.rs +++ b/src/cargo/ops/cargo_rustc/layout.rs @@ -69,9 +69,11 @@ pub struct LayoutProxy<'a> { impl Layout { pub fn new(pkg: &Package, triple: Option<&str>, dest: &str) -> Layout { let mut path = pkg.absolute_target_dir(); - match triple { - Some(s) => path.push(s), - None => {} + // Flexible target specifications often point at filenames, so interpret + // the target triple as a Path and then just use the file stem as the + // component for the directory name. + if let Some(triple) = triple { + path.push(Path::new(triple).file_stem().unwrap()); } path.push(dest); Layout::at(path) -- 2.30.2